home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / bindTest / readMe < prev   
Text File  |  1999-04-13  |  2KB  |  23 lines

  1. BindTest
  2.  
  3. by Matt Neuburg
  4. matt@tidbits.com
  5. http://www.tidbits.com/matt/
  6.  
  7. This tiny example shows why interface class inheritance is cool, and how it is used for "bindings".
  8.  
  9. The project itself doesn't do anything very interesting: you move a scrollbar or a slider (the "sender"), and its value is communicated to and displayed by either a staticText or to a progressBar (the "recipient"), depending on what choice you've made with two sets of radioButtons.
  10.  
  11. It sounds pretty simple.
  12.  
  13. But now think about this from a programming point of view. Without interface classes, the scrollbar or slider would have to know exactly who it was talking to in order to communicate its value. A staticText wants a string, and displays it in its Text property. A progressBar wants a number, and displays it in its Value property.
  14.  
  15. Also, the scrollbar or slider would have to alter a property of the staticText or progressBar, directly. That seems unpleasantly counter to proper object orientation.
  16.  
  17. That's the advantage of interface classes. The radioButtons are able to "bind" the scrollBar to the staticText, or the scrollBar to the progressBar, or the slider to the staticText, or the slider to the progressBar, and yet none of these objects needs to know the class of any of the other objects.
  18.  
  19. Furthermore, instead of the sender changing the recipient's property, the recipient inquires of the sender and changes its own property, which is much more object-oriented.
  20.  
  21. This is from my upcoming book on REALbasic. m.
  22.  
  23.